package br.com.toscano.gobra.persistence;

import java.util.List;

import javax.persistence.Query;

import br.com.toscano.gobra.domain.Licitacao;
import br.gov.frameworkdemoiselle.stereotype.PersistenceController;
import br.gov.frameworkdemoiselle.template.JPACrud;

@PersistenceController
public class LicitacaoDAO extends JPACrud<Licitacao, Long> {

	private static final long serialVersionUID = 1L;

	public Licitacao consultarLicitacao(Long idObra) {
		Query q = createQuery("from br.com.toscano.gobra.domain.Licitacao obj where obj.obra.id = :idObra" );
		q.setParameter("idObra", idObra);
		List<Licitacao> lista = q.getResultList();
		if (lista != null && lista.size()>0) 
			return lista.iterator().next();
		return null;
	}

}
